﻿using CKS2320.Common.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CKS2320.Common.Utils
{
    public class MessageInfoUtils
    {
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResultReturn Success(dynamic? data = null)
        {
            var submitReturn = new ResultReturn()
            {
                Code = 1,
                Message = "Success",
                Data = data
            };
            return submitReturn;
        }

        /// <summary>
        /// 错误信息
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public static ResultReturn Fail(string? errorMessage = null)
        {
            var submitReturn = new ResultReturn()
            {
                Code = 0,
                Message = errorMessage,
            };
            return submitReturn;
        }


        /// <summary>
        /// 错误信息
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ResultReturn Fail(dynamic data, string? errorMessage = null)
        {
            var submitReturn = new ResultReturn()
            {
                Code = -1,
                Message = errorMessage,
                Data = data
            };
            return submitReturn;
        }
    }
}
